<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Management</title>
    <link rel="stylesheet" th:href="@{/css/bootstrap4.min.css}"/>
    <script th:src="@{/js/jquery-3.6.0.min.js}"></script>
    <script th:src="@{/js/bootstrap4.min.js}"></script>
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-light bg-light">
    <a class="navbar-brand" href="#">Navigation</a>
    <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent"
            aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
        <span class="navbar-toggler-icon"></span>
    </button>

    <div class="collapse navbar-collapse" id="navbarSupportedContent">
        <ul class="navbar-nav mr-auto">
            <li class="nav-item active">
                <a class="nav-link" th:href="@{/}">Dashboard<span class="sr-only">(current)</span></a>
            </li>
        </ul>
        <ul class="nav justify-content-end">
            <li class="nav-item">
                <a class="nav-link" th:href="@{/logout}">Log Out</a>
            </li>
        </ul>
    </div>
</nav>
<div class="container">
    <div class="row">
        <div class="col-sm-2">
            <nav class="navbar navbar-light" style="background-color: #e3f2fd;">
                <ul class="navbar-nav">
                    <li class="nav-item active">
                        <a class="nav-link" th:href="@{/news/management}">Manage</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" th:href="@{/news/audit}">Audit</a>
                    </li>
                </ul>
            </nav>
        </div>
        <div class="col-sm-10">
            <table class="table">
                <thead>
                <tr>
                    <th scope="col">#</th>
                    <th scope="col">Title</th>
                    <th scope="col">Introduction</th>
                    <th scope="col">Operation</th>
                </tr>
                </thead>
                <tbody>
                <tr th:each="news,state:${list}">
                    <th scope="row" th:text="${state.index+1}"></th>
                    <td th:text="${news.title}"></td>
                    <td th:text="${news.description}"></td>
                    <td style="width: 300px">
                        <a class="btn btn-primary" th:href="@{'/news/getById/'+${news.id}}" role="button">View</a>
                        <a class="btn btn-info" th:href="@{'/news/edit/'+${news.id}}" role="button">Edit</a>
                        <a class="btn btn-danger" th:href="@{'/news/delete/'+${news.id}}" role="button">Delete</a>
                    </td>
                </tr>
                </tbody>
            </table>
            <nav aria-label="Page navigation example">
                <ul class="pagination">
                    <li th:each="i:${#numbers.sequence(1,page)}" class="page-item"
                        th:classappend="${i == pageNum}?'active':''">
                        <a class="page-link" th:href="@{'/news/management?'+'page='+${i}}" th:text="${i}"></a>
                    </li>
                </ul>
            </nav>
        </div>
    </div>
</div>
</body>
</html>
